Modèle de notebook pour écrire une réforme

Merci de ne pas modifier ce notebook, veuillez le dupliquer avant !


In [9]:
from openfisca_core import columns, entities, formulas, reforms
import openfisca_france
from openfisca_france import entities

In [10]:
tax_benefit_system = openfisca_france.init_country()()

In [11]:
Reform = reforms.make_reform(
    key = 'change_formula',
    name = u'Dummy reform with changed formula',
    reference = tax_benefit_system,
    )

In [12]:
@Reform.formula
class a(formulas.SimpleFormulaColumn):
    label = u"Charge déductibles always returning 999"
    column = columns.FloatCol
    entity_class = entities.Familles

    def function(self, simulation, period):
        return period, self.zeros() * 999

In [13]:
def modify_legislation_json(reference_legislation_json_copy):
#     reference_legislation_json_copy['children']['xxx']['values'][0]['value'] = 0
    return reference_legislation_json_copy

In [14]:
reform = Reform()
reform.modify_legislation_json(modifier_function = modify_legislation_json)

In [15]:
scenario = reform.new_scenario()

In [16]:
scenario.init_single_entity(
    period = 2015,
    parent1 = dict(
        age = 30,
        salaire_de_base = 15000,
        ),
    enfants = [
        dict(age = 10),
        dict(age = 12),
        dict(age = 18),
        ],
    )


Out[16]:
<openfisca_france.scenarios.Scenario at 0x7f4b1d9c3d10>

In [17]:
reform_simulation = scenario.new_simulation()

In [18]:
reform_simulation.calculate('a', "2015")


Out[18]:
array([ 0.], dtype=float32)

In [ ]:


In [ ]: